//
// Created by 21126 on 2023/5/19.
//
#include "U2_E3.h"

unsigned char CURTAIN_ADDRESS_E3[4] = {0x1C, 0x1D, 0x1E, 0x1F};
unsigned char HR8833MTE_ADDRESS_E3 = 0x03;

i2c_addr_def u2_e3_init(int fd)
{
    i2c_addr_def result;
    unsigned char real_slave_address;

    result.flag = 0;

    if (i2c_detect(fd, CURTAIN_ADDRESS_E3, sizeof(CURTAIN_ADDRESS_E3), &real_slave_address) >= 0)
    {
        result.fd = fd;
        result.addr = real_slave_address;
        result.flag = 1;
    }

    return result;
}

void u2_e3_set_position(int fd, unsigned char slave_address, unsigned char pos)
{
    i2c_write_byte(fd, slave_address, HR8833MTE_ADDRESS_E3, pos);
}